import { Label } from 'cc';
import { Sprite } from 'cc';
import { _decorator, Component, Node } from 'cc';
import { PROP_TYPE } from '../../../utils/Enums';
import { AudioManager } from '../../../common/src/manager/AudioManager';
import { UIManager } from '../../../framework/ui/uimanager/UIManager';
import { MonoUIPanel } from '../../../../project-base/src/scripts/MonoUIPanel';
const { ccclass, property } = _decorator;

@ccclass('PropPanel')
export class PropPanel extends MonoUIPanel {
    @property({ type: Sprite, tooltip:"道具Icon"})
    propIcon: Sprite = null;   
    @property({ type: Label, tooltip:"道具名称"})
    propName: Label = null;  
    private propType: {
        type: PROP_TYPE
    }
    start() {

    }
    /** 关闭面板. */
    public async onClosePanel() {
        AudioManager.playButton()
        await this.onExitAnimation();
        UIManager.close("prop:res/prefab/PropPanel");
    }
    public async setData(data) {
        console.log ("设置内容")
        this.propType = data
        console.log(data);
        this.initUI()
    }
    private initUI() {
        if(this.propType){
            switch(this.propType.type){
                case PROP_TYPE.刷新:
                    this.propIcon.spriteFrame = null;
                    this.propName.string = "刷新";
                    break;
                case PROP_TYPE.撤回:
                    this.propIcon.spriteFrame = null;
                    this.propName.string = "撤回";
                    break;
                case PROP_TYPE.消除:
                    this.propIcon.spriteFrame = null;
                    this.propName.string = "消除";
                    break;
            }
        }

    }
}


